package com.example.taphelper.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.example.taphelper.service.TapForegroundService

class BootReceiver : BroadcastReceiver() {
    
    companion object {
        private const val TAG = "BootReceiver"
    }
    
    override fun onReceive(context: Context, intent: Intent) {
        Log.d(TAG, "收到广播: ${intent.action}")
        
        when (intent.action) {
            Intent.ACTION_BOOT_COMPLETED,
            "android.intent.action.QUICKBOOT_POWERON" -> {
                Log.d(TAG, "设备启动完成，准备启动点击助手服务")
                
                try {
                    // 启动前台服务
                    TapForegroundService.startService(context)
                    Log.d(TAG, "前台服务启动成功")
                } catch (e: Exception) {
                    Log.e(TAG, "启动前台服务失败", e)
                }
            }
        }
    }
} 